home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 July: Mac OS SDK / Dev.CD Jul 99 SDK1.toast / Development Kits / Mac OS / Interfaces&Libraries / Universal / Interfaces / CIncludes / PCCardTuples.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-08-17  |  13.6 KB  |  468 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        PCCardTuples.h
  3.  
  4.      Contains:    List of PCMCIA tuple types and definitions of tuple contents.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Release:    Universal Interfaces 3.2
  8.  
  9.      Copyright:    © 1994-1998 by Apple Computer, Inc.  All rights reserved.
  10.  
  11.      Bugs?:        For bug reports, consult the following page on
  12.                  the World Wide Web:
  13.  
  14.                      http://developer.apple.com/bugreporter/
  15.  
  16. */
  17. #ifndef __PCCARDTUPLES__
  18. #define __PCCARDTUPLES__
  19.  
  20. #ifndef __MACTYPES__
  21. #include <MacTypes.h>
  22. #endif
  23.  
  24.  
  25.  
  26. #if PRAGMA_ONCE
  27. #pragma once
  28. #endif
  29.  
  30. #ifdef __cplusplus
  31. extern "C" {
  32. #endif
  33.  
  34. #if PRAGMA_IMPORT
  35. #pragma import on
  36. #endif
  37.  
  38. #if PRAGMA_STRUCT_ALIGN
  39.     #pragma options align=mac68k
  40. #elif PRAGMA_STRUCT_PACKPUSH
  41.     #pragma pack(push, 2)
  42. #elif PRAGMA_STRUCT_PACK
  43.     #pragma pack(2)
  44. #endif
  45.  
  46.  
  47. enum {
  48.     MAX_TUPLE_SIZE                = 256
  49. };
  50.  
  51. /*————————————————————————————————————————————————————————————————————————
  52.     Defines for Tuple codes
  53. ————————————————————————————————————————————————————————————————————————*/
  54.  
  55. enum {
  56.     CISTPL_NULL                    = 0x00,
  57.     CISTPL_DEVICE                = 0x01,
  58.     CISTPL_LONGLINK_CB            = 0x02,
  59.     CISTPL_INDIRECT                = 0x03,
  60.     CISTPL_CONFIG_CB            = 0x04,
  61.     CISTPL_CFTABLE_ENTRY_CB        = 0x05,
  62.     CISTPL_LONGLINK_MFC            = 0x06,
  63.     CISTPL_BAR                    = 0x07,
  64.     CISTPL_CHECKSUM                = 0x10,
  65.     CISTPL_LONGLINK_A            = 0x11,
  66.     CISTPL_LONGLINK_C            = 0x12,
  67.     CISTPL_LINKTARGET            = 0x13,
  68.     CISTPL_NO_LINK                = 0x14,
  69.     CISTPL_VERS_1                = 0x15,
  70.     CISTPL_ALTSTR                = 0x16,
  71.     CISTPL_DEVICE_A                = 0x17,
  72.     CISTPL_JEDEC_C                = 0x18,
  73.     CISTPL_JEDEC_A                = 0x19,
  74.     CISTPL_CONFIG                = 0x1A,
  75.     CISTPL_CFTABLE_ENTRY        = 0x1B,
  76.     CISTPL_DEVICE_OC            = 0x1C,
  77.     CISTPL_DEVICE_OA            = 0x1D,
  78.     CISTPL_DEVICE_GEO            = 0x1E,
  79.     CISTPL_DEVICE_GEO_A            = 0x1F,
  80.     CISTPL_MANFID                = 0x20,
  81.     CISTPL_FUNCID                = 0x21,
  82.     CISTPL_FUNCE                = 0x22,
  83.     CISTPL_SWIL                    = 0x23,
  84.     CISTPL_VERS_2                = 0x40,
  85.     CISTPL_FORMAT                = 0x41,
  86.     CISTPL_GEOMETRY                = 0x42,
  87.     CISTPL_BYTEORDER            = 0x43,
  88.     CISTPL_DATE                    = 0x44,
  89.     CISTPL_BATTERY                = 0x45,
  90.     CISTPL_ORG                    = 0x46,
  91.     CISTPL_VENDOR                = 0xFE,
  92.     CISTPL_END                    = 0xFF
  93. };
  94.  
  95.  
  96. /*————————————————————————————————————————————————————————————————————————
  97.     Tuple Data Block Definitions
  98. ————————————————————————————————————————————————————————————————————————*/
  99.  
  100. /*------------    Device Information Tuple (01H, 17H)    -----------                            */
  101.  
  102.  
  103. struct DeviceIDTuple {
  104.     Byte                             TPLDEV_TYPE_WPS_SPEED;        /* Device Type Code: 7-4, WPS: 3,  Device Speed: 2-0*/
  105.     Byte                             deviceData[253];
  106. };
  107. typedef struct DeviceIDTuple            DeviceIDTuple;
  108.  
  109. enum {
  110.     TPLDEV_TYPE_MASK            = 0xF0,                            /* device type mask for TPLDEV_TYPE_WPS_SPEED*/
  111.     TPLDEV_TYPE_EXTENDED        = 0xE0,                            /* device type value for extended type*/
  112.     TPLDEV_WPS_MASK                = 0x08,                            /* write-protect switch mask for TPLDEV_TYPE_WPS_SPEED*/
  113.     TPLDEV_SPEED_MASK            = 0x07,                            /* device speed mask for TPLDEV_TYPE_WPS_SPEED*/
  114.     TPLDEV_DSPEED_NULL            = 0x00,                            /* speed for null device type*/
  115.     TPLDEV_DSPEED_250NS            = 0x01,                            /* 250ns card access time*/
  116.     TPLDEV_DSPEED_200NS            = 0x02,                            /* 200ns card access time*/
  117.     TPLDEV_DSPEED_150NS            = 0x03,                            /* 150ns card access time*/
  118.     TPLDEV_DSPEED_100NS            = 0x04,                            /* 100ns card access time*/
  119.     TPLDEV_EXTENDED_SPEED        = 0x07,                            /* device speed value for extended speed*/
  120.     TPLDEV_SPEED_EXPONENT        = 0x07,                            /* extended byte exponent mask*/
  121.     TPLDEV_SPEED_MANTISSA        = 0x78,                            /* extended byte mantissa mask*/
  122.     TPLDEV_SPEED_EXTENDED_MASK    = 0x80                            /* bit set if more extended speed data follows*/
  123. };
  124.  
  125.  
  126. /*    device ID types*/
  127.  
  128.  
  129. enum {
  130.     DTYPE_NULL                    = 0,
  131.     DTYPE_ROM                    = 1,
  132.     DTYPE_OTPROM                = 2,
  133.     DTYPE_EPROM                    = 3,
  134.     DTYPE_EEPROM                = 4,
  135.     DTYPE_FLASH                    = 5,
  136.     DTYPE_SRAM                    = 6,
  137.     DTYPE_DRAM                    = 7,
  138.     DTYPE_FUNCSPEC                = 0x0D,
  139.     DTYPE_EXTEND                = 0x0E
  140. };
  141.  
  142.  
  143. /*---------------    Checksum Control Tuple (10H)    ---------------                            */
  144.  
  145.  
  146. struct ChecksumControlTuple {
  147.     short                             TPLCKS_ADDR;                /* offset to region to be checksummed, LSB first*/
  148.     short                             TPLCKS_LEN;                    /* length of region to be checksummed, LSB first*/
  149.     char                             TPLCKS_CS;                    /* checksum of the region*/
  150.     Byte                             reserved;                    /* padding*/
  151. };
  152. typedef struct ChecksumControlTuple        ChecksumControlTuple;
  153. /*----------------    Long Link Multi-Function Tuple (06H)    ------                    */
  154.  
  155.  
  156. struct LongLinkMFCTuple {
  157.     UInt8                             TPLMFC_NUM;                    /* Number of sets of config registers for individual functions*/
  158.  
  159.     UInt8                             TPLMFC_TAS1;                /* CIS target address space for first function (00 = Attr, 01 = Common)*/
  160.     UInt32                             TPLMFC_ADDR1;                /* Target address of first CIS, unsigned long, lsb first*/
  161.  
  162.     UInt8                             TPLMFC_TAS2;                /* CIS target address space for second function (00 = Attr, 01 = Common)*/
  163.     UInt8                             TPLMFC_ADDR2[4];            /* [MISALIGNED!] Target address of second CIS, unsigned long, lsb first*/
  164.  
  165.                                                                 /* the following fields are of undetermined length and should be calculated at runtime*/
  166.                                                                 /* */
  167.                                                                 /* UInt8        TPLMFC_TASn;*/
  168.                                                                 /* UInt32        TPLMFC_ADDRn;*/
  169. };
  170. typedef struct LongLinkMFCTuple            LongLinkMFCTuple;
  171. /*----------------    Long Link Tuple (11H, 12H)    ----------------                            */
  172.  
  173.  
  174. struct LongLinkTuple {
  175.     UInt32                             TPLL_ADDR;                    /* target address, LSB first*/
  176. };
  177. typedef struct LongLinkTuple            LongLinkTuple;
  178. /*-----------------    Link Target Tuple (13H)    ------------------                            */
  179.  
  180.  
  181. struct LinkTargetTuple {
  182.     Byte                             TPLL_TAG[3];                /* tag: should be 'C', 'I', 'S'*/
  183. };
  184. typedef struct LinkTargetTuple            LinkTargetTuple;
  185. /*----------------    Level 1 Version Tuple (15H)    ---------------                            */
  186.  
  187.  
  188. struct Level1VersionTuple {
  189.     Byte                             TPLLV1_MAJOR;                /* major version number (0x04)*/
  190.     Byte                             TPLLV1_MINOR;                /* minor version number (0x01 for release 2.0 and 2.01)*/
  191.     Byte                             TPLLV1_INFO[1];                /* product information string, zero-terminated*/
  192. };
  193. typedef struct Level1VersionTuple        Level1VersionTuple;
  194. /*-------------    JEDEC Identifier Tuple (18H, 19H)    ------------                            */
  195.  
  196.  
  197. struct JEDECDeviceInfo {
  198.     Byte                             manufacturerID;
  199.     Byte                             manufacturerInfo;
  200. };
  201. typedef struct JEDECDeviceInfo            JEDECDeviceInfo;
  202.  
  203. struct JEDECIdentifierTuple {
  204.     JEDECDeviceInfo                 device[1];
  205. };
  206. typedef struct JEDECIdentifierTuple        JEDECIdentifierTuple;
  207. /*---------    Configuration Tuple (1AH)    ----------                            */
  208.  
  209.  
  210. struct ConfigTuple {
  211.     Byte                             TPCC_SZ;                    /* size of fields byte*/
  212.     Byte                             TPCC_LAST;                    /* index number of last config entry*/
  213.     Byte                             TPCC_RADR;                    /* config reg's base addr in reg. space*/
  214.     Byte                             reserved;                    /* padding*/
  215.  
  216.                                                                 /* the following fields are of undetermined length and should be calculated at runtime*/
  217.                                                                 /*UInt32            TPCC_RMSK;*/
  218.                                                                 /*UInt32            TPCC_RSVD;*/
  219.                                                                 /*UInt32            TPCC_SBTPL;*/
  220. };
  221. typedef struct ConfigTuple                ConfigTuple;
  222. /*    TPCC_RADR field definitions*/
  223.  
  224. enum {
  225.     TPCC_RASZ                    = 0x03,                            /* bits 1-0*/
  226.     TPCC_RMSZ                    = 0x3C,                            /* bits 5-2*/
  227.     TPCC_RFSZ                    = 0xC0                            /* bits 7-6*/
  228. };
  229.  
  230.  
  231. /*---------    Device Geometry Tuple (1EH, 1FH)    ----------*/
  232.  
  233.  
  234. struct DeviceGeometry {
  235.     UInt8                             DGTPL_BUS;                    /* system bus width = 2^(n-1), n>0*/
  236.     UInt8                             DGTPL_EBS;                    /* erase block size = 2^(n-1), n>0*/
  237.     UInt8                             DGTPL_RBS;                    /* read block size = 2^(n-1), n>0*/
  238.     UInt8                             DGTPL_WBS;                    /* write block size = 2^(n-1), n>0*/
  239.     UInt8                             DGTPL_PART;                    /* partitioning size = 2^(n-1), n>0*/
  240.     UInt8                             DGTPL_HWIL;                    /* hardware interleave = 2^(n-1), n>0*/
  241. };
  242. typedef struct DeviceGeometry            DeviceGeometry;
  243.  
  244. struct DeviceGeometryTuple {
  245.     DeviceGeometry                     device[42];
  246. };
  247. typedef struct DeviceGeometryTuple        DeviceGeometryTuple;
  248. /*---------    Manufacturer Identification Tuple (20H)    ----------                            */
  249.  
  250.  
  251. struct ManufIDTuple {
  252.     short                             TPLMID_MANF;                /* PCMCIA PC Card manufacturer code*/
  253.     short                             TPLMID_CARD;                /* manufacturer information (part number and/or revision)*/
  254. };
  255. typedef struct ManufIDTuple                ManufIDTuple;
  256. /*-----------    Function Identification Tuple (21H)    ------------                            */
  257.  
  258.  
  259. struct FunctionIDTuple {
  260.     Byte                             TPLFID_FUNCTION;            /* PC card function code*/
  261.     Byte                             TPLFID_SYSINIT;                /* system initialization bit mask*/
  262. };
  263. typedef struct FunctionIDTuple            FunctionIDTuple;
  264. /*    function codes*/
  265.  
  266. enum {
  267.     TPLFID_MultiFunction        = 0,
  268.     TPLFID_Memory                = 1,
  269.     TPLFID_SerialPort            = 2,
  270.     TPLFID_ParallelPort            = 3,
  271.     TPLFID_FixedDisk            = 4,
  272.     TPLFID_VideoAdapter            = 5,
  273.     TPLFID_NetworkLANAdapter    = 6,
  274.     TPLFID_AIMS                    = 7,
  275.     TPLFID_SCSI                    = 8,
  276.     TPLFID_Security                = 9
  277. };
  278.  
  279.  
  280. /*------------    Software Interleave Tuple (23H)    ---------------                            */
  281.  
  282.  
  283. struct SoftwareInterleaveTuple {
  284.     char                             TPLSWIL_INTRLV;                /* software interleave*/
  285. };
  286. typedef struct SoftwareInterleaveTuple    SoftwareInterleaveTuple;
  287. /*-------    Level 2 Version and Information Tuple (40H)    --------                            */
  288.  
  289.  
  290. struct Level2VersionTuple {
  291.     Byte                             TPLLV2_VERS;                /* structure version (0x00)*/
  292.     Byte                             TPLLV2_COMPLY;                /* level of compliance with the standard (0x00)*/
  293.     UInt16                             TPLLV2_DINDEX;                /* byte address of first data byte in card, LSB first*/
  294.     Byte                             TPLLV2_RSV6;                /* reserved, must be zero*/
  295.     Byte                             TPLLV2_RSV7;                /* reserved, must be zero*/
  296.     Byte                             TPLLV2_VSPEC8;                /* vendor specific byte*/
  297.     Byte                             TPLLV2_VSPEC9;                /* vendor specific byte*/
  298.     char                             TPLLV2_NHDR;                /* number of copies of CIS present on this device*/
  299.     char                             TPLLV2_OEM[1];                /* vendor of software that formatted card, zero-terminated*/
  300.     char                             TPLLV2_INFO[1];                /* informational message about the card, zero-terminated*/
  301.     Byte                             reserved;                    /* padding*/
  302. };
  303. typedef struct Level2VersionTuple        Level2VersionTuple;
  304. /*--------------------    Format Tuple (41H)    --------------------                            */
  305.  
  306. /* additional information for disk type:*/
  307.  
  308.  
  309. struct FormatDiskTuple {
  310.     UInt16                             TPLFMT_BKSZ;                /*    block size, or zero if unblocked format*/
  311.     UInt32                             TPLFMT_NBLOCKS;                /*    number of data blocks in this partition*/
  312.     UInt32                             TPLFMT_EDCLOC;                /*    location of error detection code, or zero if interleaved*/
  313. };
  314. typedef struct FormatDiskTuple            FormatDiskTuple;
  315. /* additional information for disk type:*/
  316.  
  317. struct FormatMemTuple {
  318.     Byte                             TPLFMT_FLAGS;                /*    various flags*/
  319.     Byte                             TPLFMT_RESERVED;            /*    reserved, set to zero*/
  320.     UInt32                             TPLFMT_ADDRESS;                /*    physical location at which this memory partion must be mapped*/
  321.     UInt32                             TPLFMT_EDCLOC;                /*    location of error detection code, or zero if interleaved*/
  322. };
  323. typedef struct FormatMemTuple            FormatMemTuple;
  324.  
  325. struct FormatTuple {
  326.     char                             TPLFMT_TYPE;                /* format type code*/
  327.     char                             TPLFMT_EDC;                    /* error detection method and length of error detection code*/
  328.     long                             TPLFMT_OFFSET;                /* offset to first data byte in this partition*/
  329.     long                             TPLFMT_NBYTES;                /* number of data bytes in this partition*/
  330.     union {
  331.         FormatDiskTuple                 TPLFMT_DISK;
  332.         FormatMemTuple                     TPLFMT_MEM;
  333.     }                                 u;
  334. };
  335. typedef struct FormatTuple                FormatTuple;
  336. /*    format types*/
  337.  
  338. enum {
  339.     TPLFMTTYPE_DISK                = 0,
  340.     TPLFMTTYPE_MEM                = 1,
  341.     TPLFMTTYPE_VS                = 0x80
  342. };
  343.  
  344. /*    error detection types*/
  345.  
  346.  
  347. enum {
  348.     TPLFMTEDC_NONE                = 0,
  349.     TPLFMTEDC_CKSUM                = 1,
  350.     TPLFMTEDC_CRC                = 2,
  351.     TPLFMTEDC_PCC                = 3,
  352.     TPLFMTEDC_VS                = 8
  353. };
  354.  
  355. /*    bits in TPLFMT_FLAGS*/
  356.  
  357.  
  358. enum {
  359.     TPLFMTFLAGS_ADDR            = 0,
  360.     TPLFMTFLAGS_AUTO            = 1
  361. };
  362.  
  363.  
  364. /*------------------    Geometry Tuple (42H)    --------------------                            */
  365.  
  366.  
  367. struct GeometryTuple {
  368.     char                             TPLGEO_SPT;                    /* number of sectors per track*/
  369.     char                             TPLGEO_TPC;                    /* number of tracks per cylinder*/
  370.     short                             TPLGEO_NCYL;                /* number of cylinders, total*/
  371. };
  372. typedef struct GeometryTuple            GeometryTuple;
  373. /*-----------------    Byte-Order Tuple (43H)    -------------------                            */
  374.  
  375.  
  376. struct ByteOrderTuple {
  377.     char                             TPLBYTE_ORDER;                /* byte order code*/
  378.     char                             TPLBYTE_MAP;                /* byte mapping code*/
  379. };
  380. typedef struct ByteOrderTuple            ByteOrderTuple;
  381. /*    byte order codes*/
  382.  
  383. enum {
  384.     TYPBYTEORD_LOW                = 0,
  385.     TYPBYTEORD_HIGH                = 1,
  386.     TYPBYTEORD_VS                = 0x80
  387. };
  388.  
  389. /*    byte mapping codes*/
  390.  
  391.  
  392. enum {
  393.     TYPBYTEMAP_LOW                = 0,
  394.     TYPBYTEMAP_HIGH                = 1,
  395.     TYPBYTEMAP_VS                = 0x80
  396. };
  397.  
  398.  
  399. /*----------    Card Initialization Date Tuple (44H)    ------------                            */
  400.  
  401.  
  402. struct CardInitDateTuple {
  403.     UInt16                             TPLDATE_TIME;                /* hours, minutes, seconds*/
  404.     UInt16                             TPLDATE_DAY;                /* year, month, day*/
  405. };
  406. typedef struct CardInitDateTuple        CardInitDateTuple;
  407. /*----------    Battery-Replacement Date Tuple (45H)    ------------                            */
  408.  
  409.  
  410. struct BatteryReplaceDateTuple {
  411.     UInt16                             TPLBATT_RDAY;                /* last replacement date (year, month, day)*/
  412.     UInt16                             TPLBATT_XDAY;                /* battery expiration date (year, month, day)*/
  413. };
  414. typedef struct BatteryReplaceDateTuple    BatteryReplaceDateTuple;
  415.  
  416. /*----------------------    General Tuple    -----------------------                            */
  417.  
  418.  
  419. union TupleBody {
  420.     DeviceIDTuple                     deviceID;
  421.     ChecksumControlTuple             checksum;
  422.     LongLinkTuple                     link;
  423.     LinkTargetTuple                 target;
  424.     Level1VersionTuple                 level1;
  425.     JEDECIdentifierTuple             jedecID;
  426.     ConfigTuple                     config;
  427.     DeviceGeometryTuple             devGeo;
  428.     ManufIDTuple                     manufID;
  429.     FunctionIDTuple                 funcID;
  430.     SoftwareInterleaveTuple         swil;
  431.     Level2VersionTuple                 level2;
  432.     FormatTuple                     format;
  433.     GeometryTuple                     geometry;
  434.     ByteOrderTuple                     order;
  435.     CardInitDateTuple                 initDate;
  436.     BatteryReplaceDateTuple         battDate;
  437.     Byte                             tupleData[254];
  438. };
  439. typedef union TupleBody                    TupleBody;
  440.  
  441. struct Tuple {
  442.     Byte                             TPL_CODE;
  443.     Byte                             TPL_LINK;
  444.     TupleBody                         TPL_BODY;
  445. };
  446. typedef struct Tuple                    Tuple;
  447.  
  448. #if PRAGMA_STRUCT_ALIGN
  449.     #pragma options align=reset
  450. #elif PRAGMA_STRUCT_PACKPUSH
  451.     #pragma pack(pop)
  452. #elif PRAGMA_STRUCT_PACK
  453.     #pragma pack()
  454. #endif
  455.  
  456. #ifdef PRAGMA_IMPORT_OFF
  457. #pragma import off
  458. #elif PRAGMA_IMPORT
  459. #pragma import reset
  460. #endif
  461.  
  462. #ifdef __cplusplus
  463. }
  464. #endif
  465.  
  466. #endif /* __PCCARDTUPLES__ */
  467.  
  468.